//
//  ViewController.m
//  DR_OpenGL_Learn
//
//  Created by 3irobot2020 on 2021/10/26.
//

#import "ViewController.h"
#import "RWTVertex.h" //定义了顶点类型
#import "RWTBaseEffect.h"//用于编译glsl

@interface ViewController ()

@end

@implementation ViewController {
    GLuint _vertexBuffer;
}
 

-(void)setupVertexBuffer {
    const static RWTVertex vertices[] = {
        {{-1.0, -1.0, 1}},
        {{1.0, -1.0, 0}},
        {{0, 0, 0}}
    };
    
    //1在GPU生成 顶点缓冲区 glGenBuffers(GLsizei:个数。GLuint*  缓冲区地址)
    glGenBuffers(1, &_vertexBuffer);
    //绑定缓冲区glBindBuffer(GLenum 缓冲区类型, GLuint 缓冲区id)
    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
    //点cpu定义的顶点缓冲区传给gpu glBufferData(GLenum 缓冲区类型, GLsizeiptr 缓冲区大小, const GLvoid * 顶点数据, GLenum 缓冲区数据的作用，这里为绘制)
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //初始化上下文
    GLKView *view = (GLKView*)self.view;
    view.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect{
    glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    
    NSArray *array = @[@1,@2,@3];
    

}

 
@end
